﻿@{
    Layout = "";
}
<div ng-controller="SystemSetController">
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-12">
                <!-- START panel-->
                <div class="panel panel-default" ng-class="{ 'whirl standard': isLoading }">
                    <div class="panel-body">
                        <fieldset class="b0">
                            <legend>系统设置</legend>
                        </fieldset>
                        <fieldset>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">早查房时间：</label>
                                <div class="form-group">
                                    <label>选择日期：</label>
                                    <!--指定 date标记-->
                                    <div class='input-group date' id='datetimepicker1'>
                                        <input type='text' class="form-control" ng-model="dateOne" />
                                        <span class="input-group-addon">
                                            <span class="fa fa-calendar"></span>
                                        </span>
                                    </div>
                                </div>                                
                            </div>
                        </fieldset>
                        <fieldset>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">晚归时间</label>
                                <div class="col-lg-4">
                                    <input type="text" maxlength="10" ng-model="ResponseData.StockWarning" class="form-control" />
                                </div>
                            </div>
                            <label class="col-sm-2 control-label">—</label>
                            <div class="col-lg-4">
                                <input type="text" maxlength="200" ng-model="ResponseData.SearchKeywords" class="form-control" />
                            </div>
                        </fieldset>
                        <fieldset>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">检查修改时间</label>
                                <div class="col-lg-4">
                                    <input type="text" maxlength="10" ng-model="ResponseData.StockWarning" class="form-control" />
                                </div>
                            </div>
                        </fieldset>
                        <fieldset>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">库存不足警报</label>
                                <div class="col-lg-4">
                                    <input type="text" maxlength="10" ng-model="ResponseData.StockWarning" class="form-control" />
                                </div>
                            </div>
                        </fieldset>
                    </div>
                </div>
                <!-- END panel-->
                <div class="text-right">
                    <button type="submit" ng-click="KeyWordSave()" class="btn btn-primary">保 存</button>
                </div>

            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    App.controller('SystemSetController', ['$scope', '$resource', '$state', '$route', '$http', 'ngTableParams', 'ngTableDataService', 'Notify', '$filter', 'ngDialog', "$stateParams", "$timeout",
    function ($scope, $resource, $state, $route, $http, ngTableParams, ngTableDataService, Notify, $filter, ngDialog, $stateParams, $timeout) {
        'use strict';
        $scope.submitted = false;
        $scope.isLoading = true;
        //$scope.validateInput = function (name, type) {
        //    var input = $scope.formValidate[name];
        //    return (input.$dirty || $scope.submitted) && input.$error[type];
        //};


        //数据初始化
        $http.post("/SystemSet/SystemManage", {}).then(function (response) {
            //console.log(response);
            debugger
            $scope.ResponseData = response.data;


            //console.log($scope.ResponseData.SearchKeywords)
            $scope.isLoading = false;
        });
        //console.log("342423423423423");
        // 提交
        //$scope.submitForm = function () {
        //    $scope.submitted = true;
        //    if ($scope.formValidate.$valid) {
        //        console.log($scope.ResponseData);
        //        $http.post("/SystemSet/SystemSetSubmit", { model: $scope.ResponseData, keywordslist: $scope.ResponseData.SearchKeywords }).then(function (returnData) {
        //            if (returnData.data.isSuccess) {
        //                Notify.alert('操作成功!', { status: 'success' });
        //            } else {
        //                Notify.alert(returnData.data.msg, { status: 'warning' });
        //            }
        //        });
        //    } else {
        //        //alert("false");
        //        return false;
        //    }
        //};

        $scope.KeyWordSave = function () {
            debugger;
            $http.post("/SystemSet/KeyWordSave", $scope.ResponseData).then(function (returnData) {
                if (returnData.data.isSuccess) {
                    Notify.alert('操作成功!', { status: 'success', timeout: 1000 });
                } else {
                    Notify.alert(returnData.data.msg, { status: 'warning', timeout: 1000 });
                }
                $scope.isLoading = false;
            });
        }

        // 日期插件
        $scope.pickerMorningBegin = {
            date: new Date()
        };

        $scope.pickerMorningEnd = {
            date: new Date()
        };

        $scope.pickerNight = {
            date: new Date()
        };

        $scope.pickerModifyBegin = {
            date: new Date()
        };

        $scope.pickerModifyEnd = {
            date: new Date()
        };

        $scope.datepickerOptions = {
            showWeeks: false,
            startingDay: 1,
            dateDisabled: function (data) {
                //return (data.mode === 'day' && (new Date().toDateString() == data.date.toDateString()));
            }
        }

        $scope.openCalendar = function (e, picker) {
            $scope[picker].open = true;
        };

        //// 提交
        //$scope.submitForm = function () {
        //    debugger;
        //    $scope.isLoading = true;
        //    $scope.submitted = true;
        //    if ($scope.formValidate.$valid) {
        //        if (!$scope.Activity.CoverImg || $scope.Activity.CoverImg == "") {
        //            $scope.IsCheckedPic = true;
        //            $scope.isLoading = false;
        //            return false;
        //        }
        //        if ($scope.Activity.StartTime > $scope.Activity.EndTime) {
        //            Notify.alert('活动开始时间不能大于结束时间!', { status: 'warning', timeout: 1000 });
        //            $scope.isLoading = false;
        //            return false;
        //        }
        //        if ($scope.Activity.LuckDrawID == 0) {
        //            Notify.alert('请选择抽奖活动!', { status: 'warning', timeout: 1000 });
        //            $scope.isLoading = false;
        //            return false;
        //        }
        //        $http.post("/Activity/SaveActivity", $scope.Activity).then(function (returnData) {
        //            if (returnData.data.isSuccess) {
        //                Notify.alert('操作成功!', { status: 'success', timeout: 1000 });
        //                $state.go("app.activityList");
        //            } else {
        //                Notify.alert(returnData.data.msg, { status: 'warning', timeout: 1000 });
        //            }
        //            $scope.isLoading = false;
        //        });
        //    } else {
        //        $scope.isLoading = false;
        //        return false;
        //    }
        //};



    }]);
</script>
